PANELS

This mini-tutorial is aimed to de-mystify the panels used for user
interfaces.  In general, making fairly sophisticated interfaces is
simplicity itself using VEE but there are a few concepts that may not be
so obvious.  This is really aimed at beginners to VEE - more seasoned
programmers will find this rather basic.  Comments, ideas for
improvements etc are very welcome - please use the
Questions/Answers/Comments form on the website -
www.PreciselySo.Co.UK or e-mail to website@PreciselySo.Co.UK

DISCLAIMER, WARRANTY AND COPYRIGHT
These examples are provided on an 'as is' basis with no explicit or
implied warranty.  Copyright is retained by the author but free use
including copying and use for business purposes is expressly permitted.

This explanation goes with a set of VEE files that you should also have
- they are in VEE 5 for widest appeal.

______________

 SIMPLE START
______________

At the very simplest level a user interface is easy to set up.  For
example we have a program which works and has some control elements and
some display elements - see Panel 1.vee

To add to a panel we just click on one of the components ( "Volume",
say ) and then Ctrl-click on the others: "Frequency", "View of
waveform" and "Display fidelity", choose the Edit -> Add to Panel menu
item and we have a user interface.  Top left of this window are toggles
to switch between 'panel' and 'detail' views [Panel 2].  Simple.  A few
notes though...
now that the objects are placed on the panel they can be moved to suit;
if you need to make that object a specific size or in a particular
position then reduce the grid size ( object menu - Panel tab ) to, say,
1 ( in VEE 6 you can do precise sizing by holding the shift key before
'grabbing' a side of an object with the mouse pointer )

the data in the objects are linked panel<->detail views but the
positions, colours, sizes, scales etc are not

objects have to be in 'open' view before adding them to the panel - you
cannot open them after they are added to a panel

you can add an object to a panel more than once

to delete items on the panel right-click and choose Delete

to delete the panel use the object menu item Delete Panel

_________________

 CASCADED PANELS
_________________

It may be that you want to show an item which is in a UserObject.  In
this case the item is 2 levels down [Panel 3]

First add the objects you want to show onto Level 2 [Panel 4a].  Level 2
UserObject now has panel.  Note that I have made this fairly small.

Now open Level 1 UserObject and right-click Level 2 - choose Restore
[Panel 4b].

select the restored Level 2 and add it to Level 1's panel [Panel 4c];
in the Level 2 object properties I have unchecked Show Title bar and
again made the panel as small as possible

in Main, restore Level 1 as before [Panel 4d] click on the "Level 1",
"Volume" and "View of waveform" objects and click on the add to panel
icon ( 4th from right ).  Again remove the title bar from the Level 1
object on the panel [Panel 4e].  This provides a border around the two
user-interface objects which is ( generally ) useful to group controls
and displays on a screen.

____________________

 JUMPING JACK FLASH
____________________

And so to 'active' panels.  So far the panels described are shown when
the program starts and are closed when it stops.  There are other types
of panel operation and I am going to deal with dialog-box-style panels
and status-and-control panels.

DIALOG-BOX panels
This is straightforward.  Make your dialog box features on a
UserFunction or UserObject [Panel 5a has both].
Note:
both have an OK button - otherwise the dialog flashes up and is gone
again in an instant

Dialog 2 sets a variable ( the global TankName in this instance ).
Although it is usual for the OK button to appear bottom-right of a
dialog box, the OK button needs to be before the data object so that the
data flows to the Set Variable object.

Add the control objects to the panels [Panel 5b] - Dialog 2 OK button
has been moved to bottom-right.  In the properties for both objects
check the Show Panel On Execute box and set the Panel Title to something
meaningful.

Close the two panel windows and run the program.

Both of these panels were operating and as part of the operation
displayed their panels.  When they finished the panels were 'hidden'
again.  Now we are going to look at a three-stage operation for

STATUS & CONTROL panels
This only works for UserFunctions.  Consider having a panel on a user
function.  What does the panel do?

Nothing.  Except for looking pretty that is.  We can show the panel.  We
can hide the panel.  It does nothing.  Lets look at this a bit further.
Panel 6a shows a simple UserFunction statControl with a waveform input
and a real output.  Note the lack of an OK button.

Add to panel and move around a bit [Panel 6b].  Note that the Show Panel
On Execute is left unchecked.

Right-click on statControl in the program explorer pane and choose both
a showPanel and hidePanel formula calls.  I added a wait to allow time
for a user to see what is happening and even time to change the slider
value [Panel 6c]

Remember what is linked between panel and detail views?  The data.  So
now, if we call the function, the data will be processed as defined in
the detail view, but will also appear on the panel.  The process works
like this:

1. show the panel - note that this can be positioned to overlay other
   panels you have open at the time, can be locked into place etc.

2. call the function to update the data in the panel/read the data from
   the panel

3. if required, close the panel ( this is optional if the program is
   just going to terminate anyway )

Panel 6d shows the process.  If you are not sure how the loop works why
not have a look at the mini-tutorial on loops also found on this
website...


Michael J. Watts Consultant Sep 2001
